home *** CD-ROM | disk | FTP | other *** search
/ AGA Toolkit '97 / The AGA Toolkit '97.iso / text / misc / port / string / strfirstnum.s < prev    next >
Encoding:
Text File  |  1996-09-07  |  370 b   |  27 lines

  1.  
  2.     XDEF    StrFirstNum
  3.  
  4. ; StrFirstNum() - Finds first number ("0"-"9") in string in A0.
  5.  
  6. ; Result:
  7. ; D0 = 0 if character was not found, or the position where found.
  8.  
  9. StrFirstNum:
  10.     cmp.b    #"0",(a0)
  11.     bcc.b    .Check
  12.     addq.l    #1,a0
  13.     tst.b    (a0)
  14.     bne.b    StrFirstNum
  15.     moveq    #0,d0
  16.     rts
  17.  
  18. .Check:
  19.     cmp.b    #"9",(a0)
  20.     bls.b    .Found
  21.     addq.l    #1,a0
  22.     bne.b    StrFirstNum
  23.  
  24. .Found:
  25.     move.l    a0,d0
  26.     rts
  27.